package server.demo.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import server.demo.entity.Equipment;

import java.util.List;

@Repository
public interface EquipmentRepository extends JpaRepository<Equipment, Long> {
    
    List<Equipment> findByStatus(Equipment.EquipmentStatus status);
    
    List<Equipment> findByBrandContainingIgnoreCase(String brand);
    
    List<Equipment> findByNameContainingIgnoreCase(String name);
    
    @Query("SELECT COUNT(e) FROM Equipment e WHERE e.status = :status")
    Long countByStatus(Equipment.EquipmentStatus status);
    
    @Query("SELECT e FROM Equipment e WHERE e.categoryId = :categoryId AND e.status = 'AVAILABLE'")
    List<Equipment> findAvailableEquipmentByCategory(Long categoryId);
}